
{extend name='public/window' /}

{block name="content"}

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
            <div class="layui-tab layui-tab-brief">
                <div class="layui-tab-content" style="margin-top: 20px;">

                    <div class="layui-tab-item layui-show">

                        <div class="layui-form-item">
                            <label class="layui-form-label">题库标题：</label>
                            <div class="layui-input-block input-custom-width" style="">
                                <input type="text" name="title" value="" placeholder="请输入题库标题" lay-verify="required" lay-vertype="tips" lay-reqtext="请输入题库标题" autocomplete="off" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">题库正确答案：</label>
                            <div class="layui-input-block input-custom-width" style="">
                                {{if $info.answer}}
                                    <volist name="info.answer" id="answer">
                                        <input type="checkbox" name="answer[]" title="{$answer}" value="{$answer}" lay-skin="primary" checked>
                                    </volist>
                                {{else}}
                                    <input type="checkbox" name="answer[]" title="A" value="A" lay-skin="primary" checked>
                                    <input type="checkbox" name="answer[]" title="B" value="B" lay-skin="primary">
                                    <input type="checkbox" name="answer[]" title="C" value="C" lay-skin="primary">
                                    <input type="checkbox" name="answer[]" title="D" value="D" lay-skin="primary">
                                {{if}}
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">题库内容：</label>
                            <div class="layui-input-block input-custom-width" style="">
                                A:<input type="text" name="content[A]" value="" lay-verify="required" lay-vertype="tips"  autocomplete="off" class="layui-input ">
                                B:<input type="text" name="content[B]" value="" lay-verify="required" lay-vertype="tips"  autocomplete="off" class="layui-input ">
                                C:<input type="text" name="content[C]" value="" lay-verify="required" lay-vertype="tips"  autocomplete="off" class="layui-input ">
                                D:<input type="text" name="content[D]" value="" lay-verify="required" lay-vertype="tips"  autocomplete="off" class="layui-input ">

                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-inline input-custom-width">
                                <input type="radio" name="status" value="1" title="正常" lay-filter=""  checked>
                                <input type="radio" name="status" value="0" title="删除" lay-filter="" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-inline input-custom-width">
                                <input type="radio" name="type" value="1" title="单选" lay-filter=""  checked>
                                <input type="radio" name="type" value="2" title="多选" lay-filter="" >
                            </div>
                        </div>

                        </div>

                        {if isset($info.id)}
                        <input type="hidden" name="id" value="{$info.id}">
                        {/if}
                    </div>
            </div>
                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn" lay-submit="" lay-filter="add">{:__('Submit')}</button>
                            <button type="reset" class="layui-btn layui-btn-primary">{:__('Reset')}</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    layui.use(['element', 'form', 'jquery','lucky','upload','laydate','rate','colorpicker'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        var upload = layui.upload;
        var laydate = layui.laydate;
        var rate=layui.rate;
        var colorpicker=layui.colorpicker;


        //表单赋值
        var info = {:json_encode($info)};
        form.val("form",info);

        //表单赋值
        colorpicker.render({
            elem: '#test-form'
            ,color: '#1c97f5'
            ,done: function(color){
                $('#test-form-input').val(color);
            }
        });

        rate.render({
            elem: '#test7'
            ,length: 5
            ,setText: function(value){
                $("#tt").val(value);
            },
            value:info.range
        });

        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('upAndAdd')}",data.field,true);
            return false;
        });
    })
</script>

{/block}

